約 6,403,235 件
https://w.atwiki.jp/sicpstudygroup/pages/63.html
3 Modularity, Objects, and State 3.1 Assignment and Local State 3.1.1 Local State Variables Exercise 3.1 (define (make-accumulator augend) (lambda (addend) (begin (set! augend (+ augend addend)) augend))) by iwk Exercise 3.2 (define (make-monitored f) (let ((count 0)) (define (how-many-calls?) count) (define (reset-count) (set! count 0) count) (define (counting-procedure x) (set! count (+ count 1)) (f x)) (define (dispatch m) (cond ((eq? m how-many-calls?) (how-many-calls?)) ((eq? m reset-count) (reset-count)) (else (counting-procedure m)))) dispatch)) by iwk Exercise 3.3 (define (make-account balance passwd) (define (withdraw amount) (if ( = balance amount) (begin (set! balance (- balance amount)) balance) "Insufficient funds")) (define (deposit amount) (set! balance (+ balance amount)) balance) (define (dispatch pass m) (if (eq? pass passwd) (cond ((eq? m withdraw) withdraw) ((eq? m deposit) deposit) (else (error "Unknown request -- MAKE-ACCOUNT" m))) (error "Incorrect password" pass))) dispatch) by iwk Exercise 3.4 3.1.2 The Benefits of Introducing Assignment Exercise 3.5 Exercise 3.6 3.1.3 The Costs of Introducing Assignment Exercise 3.7 Exercise 3.8 3.2 The Environment Model of Evaluation 3.2.1 The Rules for Evaluation 3.2.2 Applying Simple Procedures Exercise 3.9 3.2.3 Frames as the Repository of Local State Exercise 3.10 3.2.4 Internal Definitions Exercise 3.11 3.3 Modeling with Mutable Data 3.3.1 Mutable List Structure Exercise 3.12 Exercise 3.13 Exercise 3.14 Exercise 3.15 Exercise 3.16 Exercise 3.17 Exercise 3.18 Exercise 3.19 Exercise 3.20 3.3.2 Representing Queues Exercise 3.21 Exercise 3.22 Exercise 3.23 3.3.3 Representing Tables Exercise 3.24 Exercise 3.25 Exercise 3.26 Exercise 3.27 3.3.4 A Simulator for Digital Circuits Exercise 3.28 Exercise 3.29 Exercise 3.30 Exercise 3.31 Exercise 3.32 3.3.5 Propagation of Constraints Exercise 3.33 Exercise 3.34 Exercise 3.35 Exercise 3.36 Exercise 3.37 3.4 Concurrency Time Is of the Essence 3.4.1 The Nature of Time in Concurrent Systems Exercise 3.38 3.4.2 Mechanisms for Controlling Concurrency Exercise 3.39 Exercise 3.40 Exercise 3.41 Exercise 3.42 Exercise 3.43 Exercise 3.44 Exercise 3.45 Exercise 3.46 Exercise 3.47 Exercise 3.48 Exercise 3.49
https://w.atwiki.jp/darwinia_jp/pages/59.html
マップエディター内で使用されるマップ上の建築物の名称です。 マップエディターに関する文献は英語しか見当たらないので、混乱を避けるためにそのままにしておきます。 間違いや疑問点がありましたらBBSをご利用ください。 行 項目 原文 訳文 半角文 1558 buildingname_invalid Invalid 1559 buildingname_factory Factory 1560 buildingname_cave Cave 1561 buildingname_radardish RadarDish 1562 buildingname_laserfence LaserFence 1563 buildingname_controltower ControlTower 1564 buildingname_gunturret GunTurret 1565 buildingname_bridge Bridge 1566 buildingname_powerstation Powerstation 1567 buildingname_tree Tree 1568 buildingname_wall Wall 1569 buildingname_trunkport TrunkPort 1570 buildingname_researchitem ResearchItem 1571 buildingname_library Library 1572 buildingname_generator Generator 1573 buildingname_pylon Pylon 1574 buildingname_pylonstart PylonStart 1575 buildingname_pylonend PylonEnd 1576 buildingname_solarpanel SolarPanel 1577 buildingname_tracklink TrackLink 1578 buildingname_trackjunction TrackJunction 1579 buildingname_trackstart TrackStart 1580 buildingname_trackend TrackEnd 1581 buildingname_refinery Refinery 1582 buildingname_mine Mine 1583 buildingname_yard Yard 1584 buildingname_displayscreen DisplayScreen 1585 buildingname_upgradeport UpgradePort 1586 buildingname_primaryupgrade PrimaryUpgrade 1587 buildingname_incubator Incubator 1588 buildingname_anthill AntHill 1589 buildingname_safearea SafeArea 1590 buildingname_triffid Triffid 1591 buildingname_spiritreceiver SpiritReceiver 1592 buildingname_receiverlink ReceiverLink 1593 buildingname_spiritspawner SpiritSpawner 1594 buildingname_spiritprocessor SpiritProcessor 1595 buildingname_spawnpoint SpawnPoint 1596 buildingname_spawnpopulationlock SpawnPopulationLock 1597 buildingname_spawnpointmaster SpawnPointMaster 1598 buildingname_spawnlink SpawnLink 1599 buildingname_aitarget AITarget 1600 buildingname_aispawnpoint AISpawnPoint 1601 buildingname_blueprintstore BlueprintStore 1602 buildingname_blueprintconsole BlueprintConsole 1603 buildingname_blueprintrelay BlueprintRelay 1604 buildingname_scripttrigger ScriptTrigger 1605 buildingname_spam Spam 1606 buildingname_goddish GodDish 1607 buildingname_staticshape StaticShape
https://w.atwiki.jp/tar0_puzzle/pages/21.html
Chapter 1.1 Exercise 1.1. 10 ;= 10 (+ 5 3 4) ;= 12 (- 9 1) ;= 8 (/ 6 2) ;= 3 (+ (* 2 4) (- 4 6)) ;= 6 (define a 3) (define b (+ a 1)) (+ a b (* a b)) ;= 19 (= a b) ;= #f (if (and ( b a) ( b (* a b))) b a) ;= 4 (cond ((= a 4) 6) ((= b 4) (+ 6 7 a)) (else 25)) ;= 16 (+ 2 (if ( b a) b a)) ;= 6 (* (cond (( a b) a) (( a b) b) (else -1)) (+ a 1)) ;= 16 テストも兼ねて解いてみた - tar0t 2010-02-09 08 03 21 名前 Exercise 1.2. (/ (+ 5 4 (- 2 (- 3 (+ 6 (/ 4 5))))) (* 3 (- 6 2) (- 2 7))) 名前 Exercise 1.3. (define (f x y z) (if ( x y) (+ (square x) (square (max y z))) (f y x z))) (define (square x) (* x x)) 名前 Exercise 1.4 (define (a-plus-abs-b a b) ((if ( b 0) + -) a b)) ;; (a-plus-abs-b 10 -3) ;; Applicative evaluation ((if #f + -) 10 -3)) ;; (- 10 -3) 13 ;; Normal ((if ( -3 0) + -) 10 -3)) ((if #f + -) 10 -3)) (- 10 -3) 13 Exercise1.5 (test 0 (p)) ;; Applicative (test 0 ;*evaluate(p)*) == (test 0 (p)) (test 0 (p)) (test 0 (p)) ... ;; Normal (test 0 (p)) (if (= 0 0) 0 (p)) (if #t 0 (p)) 0 Exercise1.6 (define (new-test x y) (new-if (= x 0) 0 y)) (define (p) (p)) (new-test 0 (p)) ;; Normal (new-if (= 0 0) 0 (p)) (cond ((= 0 0) 0) (else (p)))) 0 ;; 1.7 大きな数字の場合に, 接線の傾きが無限大になる = y軸とほぼ平行になるから処理が終わらない 小さすぎるときは, 接線の傾きがx軸とほぼ平行になるから, 次回が大きな数字から始まることになるから処理が終わらない 1.8 (define (cube-iter guess x) (if (good-enough? guess x) guess (cube-iter (improve guess x) x))) (define (improve y x) (/ (+ (/ x (* y y)) (+ y y)) 3)) (define (cube y) (* y y y)) (define (good-enough? guess x) ( (abs (- (cube guess) x)) 0.001)) (define (cbrt x) (cube-iter 1.0 x))
https://w.atwiki.jp/tar0_puzzle/pages/38.html
Chapter 2.2.4 Picture Language 描画結果 名前 Exercise 2.44 (define (align-operator combiner op1 op2) (lambda (painter) (combiner (op1 painter) (op2 painter)))) (define align-vert (align-operator below identity identity)) (define align-horiz (align-operator beside identity identity)) (define (up-split painter n) (if (= n 0) painter (below painter (align-horiz (up-split painter (- n 1)))))) Exercise 2.45 (define right-split (split beside below)) (define up-split (split below beside)) (define (split align-identity align-splitted) (define (splitter painter n) (if (= n 0) painter (align-identity painter ((align-operator align-splitted) (splitter painter (- n 1)))))) splitter) 以降はFrame, Painterの実装について Exercise 2.46 ; vector constructor and selectors ; vector operating procedures (define make-vect cons) (define x-vect car) (define y-vect cdr) (define (add-vect u v) (make-vect (+ (x-vect u) (x-vect v)) (+ (y-vect u) (y-vect v)))) (define (sub-vect u v) (make-vect (- (x-vect u) (x-vect v)) (- (y-vect u) (y-vect v)))) (define (scale-vect a v) (make-vect (* a (x-vect v)) (* a (y-vect v)))) Exercise 2.47 ; implementing a frame (define (make-frame1 origin h-edge v-edge) (list origin h-edge v-edge)) (define origin-frame1 car) (define h-edge-frame1 (lambda (x) (car (cdr x)))) (define v-edge-frame1 (lambda (x) (car (cdr (cdr x))))) (define (make-frame2 origin h-edge v-edge) (cons origin (cons h-edge v-edge))) (define origin-frame2 car) (define h-edge-frame2 (lambda (x) (cdr (car x)))) (define v-edge-frame2 (lambda (x) (cdr (cdr x)))) Exercise 2.48 ; segment 線分 = 始点, 終点 (define make-segment cons) (define start-segment car) (define end-segment cdr) Exercise 2.49 implementing some primitive painters ; outline draws the outlines of the given frame ; diagonal draws an X by connecting opposite corners ; diamond draws a diamond shape by connecting midpoint of sides ; wave (define outline (segment- painter (list (make-segment (make-vect 0.0 0.0) (make-vect 1.0 0.0)) (make-segment (make-vect 1.0 0.0) (make-vect 1.0 1.0)) (make-segment (make-vect 1.0 1.0) (make-vect 0.0 1.0)) (make-segment (make-vect 0.0 1.0) (make-vect 0.0 0.0))))) (define diagonal (segment- painter (list (make-segment (make-vect 0.0 0.0) (make-vect 1.0 1.0)) (make-segment (make-vect 1.0 0.0) (make-vect 0.0 1.0))))) (define diamond (segment- painter (list (make-segment (make-vect 0.0 0.5) (make-vect 0.5 1.0)) (make-segment (make-vect 0.5 1.0) (make-vect 0.5 0.0)) (make-segment (make-vect 0.5 0.0) (make-vect 0.0 0.5))))) (define wave (segment- painter (list (make-segment (make-vect 0.0 0.86) (make-vect 0.14 0.6)) (make-segment (make-vect 0.14 0.6) (make-vect 0.25 0.64)) (make-segment (make-vect 0.25 0.64) (make-vect 0.39 0.64)) (make-segment (make-vect 0.39 0.64) (make-vect 0.36 0.86)) (make-segment (make-vect 0.36 0.86) (make-vect 0.39 1.0)) ;; (make-segment (make-vect 0.61 1.0) (make-vect 0.64 0.86)) (make-segment (make-vect 0.64 0.86) (make-vect 0.61 0.64)) (make-segment (make-vect 0.61 0.64) (make-vect 0.75 0.64)) (make-segment (make-vect 0.75 0.64) (make-vect 1.0 0.35)) ;; (make-segment (make-vect 0.0 0.64) (make-vect 0.14 0.39)) (make-segment (make-vect 0.14 0.39) (make-vect 0.25 0.6)) (make-segment (make-vect 0.25 0.6) (make-vect 0.36 0.5)) (make-segment (make-vect 0.36 0.5) (make-vect 0.25 0.0)) ;; (make-segment (make-vect 0.39 0.0) (make-vect 0.5 0.29)) (make-segment (make-vect 0.5 0.29) (make-vect 0.61 0.0)) ;; (make-segment (make-vect 0.75 0.0) (make-vect 0.61 0.47)) (make-segment (make-vect 0.61 0.47) (make-vect 1.0 0.14))))) Exercise 2.50 (define (flip-vert painter) (transform-painter painter (make-vect 0.0 1.0) (make-vect 1.0 1.0) (make-vect 0.0 0.0))) (define (flip-horiz painter) (transform-painter painter (make-vect 1.0 0.0) (make-vect 0.0 0.0) (make-vect 1.0 1.0))) (define (rotate180 painter) (transform-painter painter (make-vect 1.0 1.0) (make-vect 0.0 1.0) (make-vect 1.0 0.0))) (define (rotate90 painter) (transform-painter painter (make-vect 1.0 0.0) (make-vect 1.0 1.0) (make-vect 0.0 0.0))) (define (rotate270 painter) (transform-painter painter (make-vect 0.0 1.0) (make-vect 0.0 0.0) (make-vect 1.0 1.0))) Exercise 2.51 (define (beside painter1 painter2) (let ((paint-left (transform-painter painter1 (make-vect 0.0 0.0) (make-vect 0.5 0.0) (make-vect 0.0 1.0))) (paint-right (transform-painter painter2 (make-vect 0.5 0.0) (make-vect 1.0 0.0) (make-vect 0.5 1.0)))) (lambda (frame) (paint-left frame) (paint-right frame)))) (define (below painter1 painter2) (let ((paint-bottom (transform-painter painter1 (make-vect 0.0 0.0) (make-vect 1.0 0.0) (make-vect 0.0 0.5))) (paint-top (transform-painter painter2 (make-vect 0.0 0.5) (make-vect 1.0 0.5) (make-vect 0.0 1.0)))) (lambda (frame) (paint-top frame) (paint-bottom frame))))
https://w.atwiki.jp/harucraft/pages/38.html
Renard City (The Capital) Building Rules ONLY Licensed Person can build in this city.(Please apply to OP or Guardian to obtain the license.) Do NOT mar the beauty of scenery. Minimize a gap between buildings. There must be two blocks width space between waterway and building. Buildings must be come up to use of each area. Light up your buildings and parcels. Building structure by Bricks is encouraged.(Not forced.) Building structure into Priority Area is encouraged.(Not forced.) Do NOT create Nether Gate by yourself. Note 1 Renard City has a radius of 500 blocks. Note 2 After you bought a region in this city... Remove Lockette Protection Signs from your chests in your protected region. Trap Tower World Building Rules You can ONLY build Trap Tower(MOB Tower, MOB Farm) in this world. MOB-Spawn Suffocating System must be furnished. And it must be activated automatically by timer. Light up MOB Spawn Area when your Trap Tower is not running. Note OP will break Spawn Block and Spawn Floor of your Trap Tower if you break even one of these rules. And a lot of fee will charged you to restore them by OP. Limitation of your mobs amount There are mobs keeping limits in this server. Do NOT over them at each world. List of limits Main World 15 Mobs Free World 15 Mobs Trap Tower World 100 Mobs Other Worlds 15 Mobs
https://w.atwiki.jp/hebolisper/pages/19.html
Exercise 2.3[h] 小さな別の文法を書きなさい。自然言語でもcomputer言語のサブセットでも構いません Exercise 2.4 [m] combine-allを記述する方法として引数listをappendする計算を行う関数cross-productを使って書くことができます。cross-productを高階関数として記述し、それを使ってcombine-allを定義しなさい。次にどのような変更があってもいいように、できるだけ一般化した形で書きなさい。
https://w.atwiki.jp/tar0_puzzle/pages/37.html
Chapter 2.2.2 名前 Exercise 2.24 (define ans (cons 1 (cons (cons 2 (cons (cons 3 (cons 4 ())) ())) ()))) Exercise 2.25 (define (pick x ls) (define (sub x ls) (if (null? ls) false (if (pair? ls) (pick x ls) (if (= x ls) true false)))) (if (not (sub x (car ls))) (sub x (cdr ls)) true)) Exercise 2.26 (define x (list 1 2 3)) (define y (list 4 5 6)) (append x y) (1 2 3 4 5 6) (cons x y) ((1 2 3) 4 5 6) (list x y) ((1 2 3) (4 5 6)) Exercise 2.27 (define (rev ls) (define (it ls re) (if (null? ls) re (it (cdr ls) (cons (car ls) re)))) (it ls ())) (define (d-rev ls) (define (it ls re) (if (null? ls) re (if (pair? (car ls)) (it (cdr ls) (cons (d-rev (car ls)) re)) (it (cdr ls) (cons (car ls) re))))) (it ls ())) Exercise 2.28 (define (fringe ls) (if (null? ls) () (if (pair? (car ls)) (fringe (append (car ls) (fringe (cdr ls)))) (cons (car ls) (fringe (cdr ls)))))) Exercise 2.29 Exercise 2.30 (define (square-tree tree) (define (square x) (* x x)) (map (lambda (sub) (if (pair? sub) (square-tree sub) (square sub))) tree)) Exercise 2.31 (define (tree-map f tree) (map (lambda (x) (if (pair? x) (tree-map f x) (f x))) tree)) Exercise 2.32 (define (subsets s) (define (g x) (cons (car s) x)) (if (null? s) (list ()) (let ((rest (subsets (cdr s)))) (append rest (map g rest)))))
https://w.atwiki.jp/sicpstudygroup/pages/50.html
Exercise2.17 (define (last-pair xs) (if (null? (cdr xs)) xs (last-pair (cdr xs)))) by iwk Exercise2.18 (define (reverse xs) (if (null? xs) () (append (reverse (cdr xs)) (list (car xs))))) by iwk Exercise2.19 (define us-coins (list 50 25 10 5 1)) (define uk-coins (list 100 50 20 10 5 2 1 0.5)) (define (cc amount coin-values) (cond ((= amount 0) 1) ((or ( amount 0) (no-more? coin-values)) 0) (else (+ (cc amount (except-first-denomination coin-values)) (cc (- amount (first-denomination coin-values)) coin-values))))) (define (first-denomination coin-values) (car coin-values)) (define (except-first-denomination coin-values) (cdr coin-values)) (define (no-more? coin-values) (null? coin-values)) by iwk Exercise2.20 (define (filter p xs) (cond ((null? xs) ()) ((p (car xs)) (cons (car xs) (filter p (cdr xs)))) (else (filter p (cdr xs))))) (define same-parity (lambda w (let ((parity (if (even? (car w)) even? odd?))) (filter parity w)))) by iwk Exercise2.21 (define (square-list-it items) (if (null? items) () (cons (square (car items)) (square-list-it (cdr items))))) (define (square-list items) (map square items)) by iwk Exercise2.22 (define (square-list-it items) (define (square x) (* x x)) (define (iter xs cont) (if (null? xs) (cont ()) (iter (cdr xs) (lambda (c) (cont (cons (square (car xs)) c)))))) (iter items (lambda (x) x))) by iwk Exercise2.23 (define (foreach proc xs) (if (null? (cdr xs)) (proc (car xs)) (let ((tmp (proc (car xs)))) (foreach proc (cdr xs))))) by iwk Exercise2.24 Exercise2.25 (car (cdaddr (1 3 (5 7) 9))) = 7 (caar ((7))) = 7 (cadadr (cadadr (cadadr (1 (2 (3 (4 (5 (6 7))))))))) = 7 author iwk Exercise2.26 (define x (list 1 2 3)) (define y (list 4 5 6)) (append x y) = (1 2 3 4 5 6) (cons x y) = ((1 2 3) 4 5 6) (list x y) = ((1 2 3) (4 5 6)) author iwk Exercise2.27 (define (deep-reverse xxs) (if (null? xxs) () (let ((x (car xxs)) (xs (cdr xxs))) (append (deep-reverse xs) (list (if (pair? x) (reverse x) x)))))) author iwk Exercise2.28 (define (fringe tree) (cond ((null? tree) ()) ((not (pair? tree)) (list tree)) (else (append (fringe (car tree)) (fringe (cdr tree)))))) author iwk Exercise2.29 Exercise2.30 (define (square x) (* x x)) (define (square-tree-directly tree) (cond ((null? tree) ()) ((pair? tree) (cons (square-tree-directly (car tree)) (square-tree-directly (cdr tree)))) (else (square tree)))) (define (square-tree-map tree) (cond ((number? tree) (square tree)) (else (map square-tree-map tree)))) author iwk Exercise2.31 (define (tree-map proc tree) (cond ((list? tree) (map (lambda (subtree) (tree-map proc subtree)) tree)) ((pair? tree) (cons (proc (car tree)) (proc (cdr tree)))) (else (proc tree)))) author iwk Exercise2.32 Exercise2.33 (define (map proc sequence) (accumulate (lambda (x y) (cons (proc x) y)) () sequence)) (define (append fseq sseq) (accumulate cons sseq fseq)) (define (length sequence) (accumulate (lambda (x y) (+ 1 (length (cdr sequence)))) 0 sequence)) author iwk Exercise2.34 (define (horner-eval x coefficient-sequence) (accumulate (lambda (this-coeff higher-terms) (+ this-coeff (* higher-terms x))) 0 coefficient-sequence)) author iwk Exercise2.34 (define (horner-eval x coefficient-sequence) (accumulate (lambda (this-coeff higher-terms) (+ this-coeff (* higher-terms x))) 0 coefficient-sequence)) author iwk Exercise2.35 (define (count-leaves tree) (accumulate + 0 (map (lambda (x) (if (pair? x) (count-leaves x) 1)) tree))) author iwk Exercise2.36 (define (accumulate-n op init seqs) (if (null? (car seqs)) () (cons (accumulate op init (map car seqs)) (accumulate-n op init (map cdr seqs))))) author iwk Exercise2.37 (define (transpose mat) (accumulate-n cons () mat)) (define (row-vector- list cont-vector) (car cont-vector)) (define (dot-product v w) (fold-right + 0 (map * v w))) (define (matrix-*-vector m v) (map (lambda (w) (dot-product w v)) m)) (define (matrix-*-matrix m n) (let ((transposed-n (transpose n))) (map (lambda (w) (matrix-*-vector m w)) n))) author iwk Exercise2.38 (define (fold-left op initial sequence) (define (iter result rest) (if (null? rest) result (iter (op result (car rest)) (cdr rest)))) (iter initial sequence)) author iwk Exercise2.39 (define (reverse-r sequence) (use srfi-1) (fold-right (lambda (x y) (append y (list x))) () sequence)) (define (reverse-l sequence) (use srfi-1) (fold-left (lambda (x y) (cons y x)) () sequence)) author iwk Exercise2.40 Exercise2.41 Exercise2.42 Exercise2.43 Exercise2.44 (define (up-split painter n) (if (= n 0) painter (let ((smaller (up-split painter (- n 1)))) (below painter (beside smaller smaller))))) author iwk Exercise2.45 (define right-split (split beside below)) (define up-split (split below beside)) (define (split p q) (lambda (painter n) (if (= n 0) painter (let ((smaller ((split p q) painter (- n 1)))) (p painter (q smaller smaller)))))) author iwk Exercise2.46 (define (make-vect x y) (cons x y)) (define (xcor-vect v) (car v)) (define (ycor-vect v) (cdr v)) (define (add-vect v w) (make-vect (+ (xcor-vect v) (xcor-vect w)) (+ (ycor-vect v) (ycor-vect w)))) (define (sub-vect v w) (make-vect (- (xcor-vect v) (xcor-vect w)) (- (ycor-vect v) (ycor-vect w)))) (define (scale-vect s v) (make-vect (* s (xcor-vect v)) (* s (ycor-vect v)))) author iwk Exercise2.47 (define (make-frame-l origin edge1 edge2) (list origin edge1 edge2)) (define (origin-frame-l f) (list-ref f 0)) (define (xedge-frame-l f) (list-ref f 1)) (define (yedge-frame-l f) (list-ref f 2)) (define (make-frame-c origin edge1 edge2) (cons origin (cons edge1 edge2))) (define (origin-frame-c f) (car f)) (define (xedge-frame-c f) (cadr f)) (define (yedge-frame-c f) (cddr f)) author iwk Exercise2.48 (define (make-segment start-vect end-vect) (cons start-vect end-vect)) (define (start-vect seg) (car seg)) (define (end-vect seg) (cdr seg)) Exercise2.49 Exercise2.50 Exercise2.51 Exercise2.52
https://w.atwiki.jp/hr_nico25/pages/17.html
Please be building it from releasing two trout from the road Please take permission from the creators of next to the building , such as if the building may overlap . Architecture thank you away three blocks from the road . (Of which one block half block Underground branch for securing resources is BAN subject , but mining in the construction purpose is possible . Thank you so soon be answered because also there may be when the operator hears a purpose . Please type in the ID in the sign in their building . I will remove the building if it is not already driven within one week You only certain period of time and you might want to erase the middle of the building .
https://w.atwiki.jp/sicpstudygroup/pages/54.html
Exercise2.53 gosh (print (list a b c)) (a b c) # undef gosh (print (list (list george))) ((george)) # undef gosh (print (cdr ((x1 x2) (y1 y2)))) ((y1 y2)) # undef gosh (print (cadr ((x1 x2) (y1 y2)))) (y1 y2) # undef gosh (print (pair? (car (a short list)))) #f # undef gosh (memq red ((red shoes) (blue socks)))) #f gosh (memq red (red shoes blue socks)) (red shoes blue socks) by iwk Exercise2.54 (define (myequal? x y) (cond ((and (null? x) (null? y)) #t) ((and (list? x) (list? y)) (and (myequal? (car x) (car y)) (myequal? (cdr x) (cdr y)))) (else (eq? x y)))) by iwk Exercise2.55 まず、quote手続きと" "の関係について述べる。 R5RSによると datum は (quote datum ) の単なる省略であると規定されている。 そして、また以下のようなことが成り立つ。 (quote a) = (quote a) a = (quote a) これを踏まえ問題を解いてみる。 abracadabra はR5RSによれば abracadabra = (quote abracadabra) と評価される。すなわち、データ形式で表現すると [・][・] - [・][/] ↓ ↓ [quote] [abracadabra] というリストになっている。第一要素はquoteであるので このリストをcarすればquoteが返る。 by iwk Exercise2.56 (define (exponentiation? x) (and (pair? x) (eq? (car x) **))) (define (base exp) (cadr exp)) (define (exponent exp) (caddr exp)) (define (make-exponentiation base pow) (cond ((=number? pow 0) 1) ((=number? pow 1) base) ((=number? base 0) 0) (else (list ** base pow)))) (define (deriv exp var) (cond ((number? exp) 0) ((variable? exp) (if (same-variable? exp var) 1 0)) ((sum? exp) (make-sum (deriv (addend exp) var) (deriv (augend exp) var))) ((product? exp) (make-sum (make-product (multiplier exp) (deriv (multiplicand exp) var)) (make-product (deriv (multiplier exp) var) (multiplicand exp)))) ((exponentiation? exp) (make-product (make-product (exponent exp) (make-exponentiation (base exp) (- (exponent exp) 1))) (deriv (base exp) var))) (else (error "unknown expressin type --DERIV" exp)))) by iwk Exercise2.57 (define (augend s) (let ((as (cddr s))) (if (null? (cdr as)) (car as) (cons + as)))) (define (multiplicand p) (let ((ms (cddr p))) (if (null? (cdr ms)) (car ms) (cons * ms)))) by iwk Exercise2.58 a. (define (make-infix-sum a1 a2) (cond ((=number? a1 0) a2) ((=number? a2 0) a1) (else (list a1 + a2)))) (define (make-infix-product m1 m2) (cond ((or (=number? m1 0) (=number? m2 0)) 0) ((=number? m1 1) m2) ((=number? m2 1) m1) (else (list m1 * m2)))) (define (infix-sum? x) (and (pair? x) (eq? (cadr x) +))) (define (infix-addend s) (car s)) (define (infix-augend s) (caddr s)) (define (infix-product? x) (and (pair? x) (eq? (cadr x) *))) (define (infix-multiplier p) (car p)) (define (infix-multiplicand p) (caddr p)) (define (derive exp var) (cond ((number? exp) 0) ((variable? exp) (if (same-variable? exp var) 1 0)) ((infix-sum? exp) (make-infix-sum (derive (infix-addend exp) var) (derive (infix-augend exp) var))) ((infix-product? exp) (make-infix-sum (make-infix-product (infix-multiplier exp) (derive (infix-multiplicand exp) var)) (make-infix-product (derive (infix-multiplier exp) var) (infix-multiplicand exp)))) ((exponentiation? exp) (make-product (make-product (exponent exp) (make-exponentiation (base exp) (- (exponent exp) 1))) (deriv (base exp) var))) (else (error "unknown expressin type --DERIV" exp)))) b. (define (make-infix-sum a1 a2) (cond ((=number? a1 0) a2) ((=number? a2 0) a1) ((infix-sum? a2) (cons a1 (cons + a2))) ((infix-product? a2) (cons a1 (cons * a2))) ((and (number? a1) (number? a2)) (+ a1 a2)) (else (list a1 + a2)))) (define (make-infix-product m1 m2) (cond ((or (=number? m1 0) (=number? m2 0)) 0) ((=number? m1 1) m2) ((=number? m2 1) m1) ((and (number? m1) (number? m2)) (* m1 m2)) (else (list m1 * m2)))) (define (infix-sum? x) (and (pair? x) (eq? (cadr x) +))) (define (infix-addend s) (car s)) (define (infix-augend s) (let ((as (cddr s))) (if (null? (cdr as)) (car as) as))) (define (infix-product? x) (and (pair? x) (eq? (cadr x) *))) (define (infix-multiplier p) (car p)) (define (infix-multiplicand p) (let ((ms (cddr p))) (if (null? (cdr ms)) (car ms) ms))) by iwk Exercise2.59 (use srfi-1) (define (union-set set1 set2) (append (append-map (lambda (x) (if (element-of-set? x set2) () (list x))) set1) set2)) by iwk Exercise2.60 Exercise2.61 (define (pivot xs) (cond ((or (null? xs) (null? (cdr xs))) done) (( = (car xs) (cadr xs)) (pivot (cdr xs))) (else (car xs)))) (define (partition piv xs lt mt) (if (null? xs) (cons lt mt) (if ( (car xs) piv) (partition piv (cdr xs) (cons (car xs) lt) mt) (partition piv (cdr xs) lt (cons (car xs) mt))))) (define (qsort xs) (let ((piv (pivot xs))) (if (equal? piv done) xs (let* ((parts (partition piv xs () ())) (lt (car parts)) (mt (cdr parts))) (append (qsort lt) (qsort mt)))))) (define (adjoin-ordered-set x set) (if (element-of-ordered-set? x set) set (qsort (cons x set)))) by iwk Exercise2.62 Exercise2.63 Exercise2.64 Exercise2.65 Exercise2.66 Exercise2.67 gosh (decode sample-message sample-tree) (A D A B B C A) by iwk Exercise2.68 (define (encode message tree) (if (null? message) () (append (encode-symbol (car message) tree) (encode (cdr message) tree)))) (define (encode-symbol s tree) (if (leaf? tree) () (let* ((left (left-branch tree)) (lsymbol (symbols left)) (right (right-branch tree)) (rsymbol (symbols right))) (cond ((elem s lsymbol) (cons 0 (encode-symbol s left))) ((elem s rsymbol) (cons 1 (encode-symbol s right))) (else (error "can t reach the leaf that holds the symbol -- ENCODE-SYMBOL" tree)))))) (define (elem x xs) (cond ((null? xs) #f) ((equal? x (car xs)) #t) (else (elem x (cdr xs))))) by iwk Exercise2.69 (define (generate-huffman-tree pairs) (successive-merge (make-leaf-set pairs))) (define (successive-merge leaves) (cond ((null? leaves) ()) ((null? (cdr leaves)) (car leaves)) (else (let ((ls (quick-huffman-sort leaves))) (successive-merge (cons (make-code-tree (car ls) (cadr ls)) (cddr ls))))))) (define (sorted? xs functor) (if (or (null? xs) (null? (cdr xs))) #t (let ((first (car xs)) (second (cadr xs))) (and (or ((functor =) first second) ((functor ) first second)) (sorted? (cdr xs) functor))))) (define (split piv xs lt mt functor) (cond ((null? xs) (cons lt mt)) (((functor ) (car xs) piv) (split piv (cdr xs) (cons (car xs) lt) mt functor)) (else (split piv (cdr xs) lt (cons (car xs) mt) functor)))) (define (quick-sort xs functor) (if (sorted? xs functor) xs (let* ((mean (- (quotient (length xs) 2) 1)) (piv (list-ref xs mean)) (splited (split piv xs () () functor)) (lt (car splited)) (mt (cdr splited))) (append (quick-sort lt functor) (quick-sort mt functor))))) (define (quick-huffman-sort xs) (quick-sort xs (lambda (op) (lambda (x y) (op (weight x) (weight y)))))) by iwk Exercise2.70 (define rock-pairs ((A 2) (NA 16) (BOOM 1) (SHA 3) (GET 2) (YIP 9) (JOB 2) (WAH 1))) (define rock-tree (generate-huffman-tree rock-pairs)) (define rock-phrase (GET A JOB SHA NA NA NA NA NA NA NA NA GET A JOB SHA NA NA NA NA NA NA NA NA WAH YIP YIP YIP YIP YIP YIP YIP YIP YIP SHA BOOM)) gosh (encode rock-phrase rock-tree) (1 1 0 0 1 1 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 0 0 1 1 0 1 1 1 1 1 1 1 1 1 0 0 0 0 0 0 0 0 0 1 1 1 1 0 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 0 1 1 1 0 1 1 1 1 0 1) by iwk Exercise2.71 (use srfi-13) (define (make-pairs n) (let* ((init (char- integer #\A)) (table (string-tabulate (compose integer- char (pa$ + init)) n)) (symlist ((compose (map$ (compose string- symbol list- string list)) string- list) table)) ) (list-ec ( parallel ( list s symlist) ( i (+ n 1))) (list s (expt 2 i))))) (define (pow-tree n) (generate-huffman-tree (make-pairs n))) (define tree-5 (pow-tree 5)) (define tree-10 (pow-tree 10)) ;gosh (encode (A) tree-5) ;(0 0 0 0) ;gosh (encode (E) tree-5) ;(1) ; ;gosh (encode (A) tree-10) ;(0 0 0 0 0 0 0 0 0) ;gosh (encode (J) tree-10) ;(1) by iwk